package org.gjy.m8.file;

import org.junit.Test;

import java.io.File;
import java.io.FileWriter;

/**
 * @author gjy
 * @version 1.0
 * @since 2024-02-29 16:05:36
 */
public class FileWriteTest {

    @Test
    public void test1() {
        String f = "D:\\code\\java\\microservice_spc\\jdk_basic\\src\\main\\resources\\hello.txt";
        String data = "hello|wwwo|12222|003021\niiid|12222|03932||12233";
        try (FileWriter fw = new FileWriter(f)) {
            fw.write(data);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

    @Test
    public void test2() {
        String f1 = "D:\\code\\java\\microservice_spc\\jdk_basic\\src\\main\\resources\\hello.txt";
        String f2 = "D:\\code\\java\\microservice_spc\\jdk_basic\\src\\main\\resources\\hello-99.txt";

        boolean b = new File(f1).renameTo(new File(f2));
        System.out.println(b);
    }

    @Test
    public void test3() {
        String sql = "selEct * from a";
        String s = sql.replaceAll("(?i)SELECT", "DELETE");
        System.out.println(s);
    }
}
